﻿<navigation:Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="ibba.src.noriskbo.PageEnquadramento" 
    xmlns:ig="http://schemas.infragistics.com/xaml"    
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:converter="clr-namespace:ibba.src.noriskbo.code.converter"
    xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"   
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"  
    xmlns:behavior="clr-namespace:ibba.src.noriskbo.code.behavior"
    xmlns:slc="clr-namespace:ibba.src.sl.componentes;assembly=ibba.src.sl.componentes"
    Title="Enquadramento Manual"
    d:DesignWidth="960" d:MinHeight="550" 
    FontSize="10.667">

    <navigation:Page.Resources>
        <slc:SwitchConverter x:Key="RunoffToBrushConverter" Else="Black">
            <slc:SwitchCase When="true" Then="Red"/>
        </slc:SwitchConverter>
        
        <converter:ComandadoConverter x:Key="ComandadoConverter" />

        <Style x:Key="CenterAlignStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Center" />
        </Style>
        <Style x:Key="RightAlignStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Right" />
        </Style>
        <Style x:Key="WordWrapp" TargetType="TextBlock">
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>        
    </navigation:Page.Resources>
    
    
    <Grid x:Name="LayoutRoot" Margin="10,5,10,5">

        <toolkit:BusyIndicator x:Name="activity">

            <Grid Background="White">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <TextBlock Name="lblTituloPagina" Text="Titulo da Pagina" Style="{StaticResource TitlePage}" Grid.RowSpan="2" />

                <TextBlock Name="lblResultadoSubLimites" Text="Nenhum sublimite encontrado."
                           Margin="5,10,0,0" FontSize="24" FontWeight="Bold" Visibility="Collapsed" 
                           VerticalAlignment="Top" Grid.Row="0"/>

                <StackPanel Name="panelSublimite" Grid.Row="0" SizeChanged="panelSublimite_SizeChanged">
                    <Grid Name="gridSubLimites" Grid.Row="0" Margin="0,2,0,0"
                          Visibility="Collapsed">

                        <toolkit:Expander x:Name="expSubLimites" Header="Sublimites"
                                      HorizontalAlignment="Stretch" VerticalAlignment="Top"                                       
                                      Background="White" IsExpanded="True">
                            <toolkit:Expander.HeaderTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,-1,0,0">
                                        <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
                                            <TextBlock Text="{Binding Path=Header, ElementName=expSubLimites}" FontSize="14" Foreground="#FFE78E21"/>
                                            <TextBlock Text="{Binding Path=Tag, ElementName=expSubLimites}" Margin="5,0,0,0" FontSize="14" Foreground="#FFE78E21" />
                                        </StackPanel>
                                        <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>
                                    </StackPanel>
                                </DataTemplate>
                            </toolkit:Expander.HeaderTemplate>

                            <Grid>
                                <ig:XamGrid Name="grdSublimites" Margin="0,5,0,5"
                                            AutoGenerateColumns="False" >
                                    <i:Interaction.Behaviors>
                                        <behavior:XamGridBehavior x:Name="grdSublimitesBehavior" IsExpandRowGrouped="True" />
                                    </i:Interaction.Behaviors>
                                    
                                    <ig:XamGrid.Columns>
                                        <ig:TextColumn HeaderText="Id" Key="IdSubLimite" Visibility="Collapsed" IsHideable="False" />
                                        <ig:TextColumn HeaderText="Descrição" Key="Descricao" MinimumWidth="400" Width="*" TextWrapping="Wrap" IsHideable="False" />
                                        <ig:TextColumn HeaderText="Limite em Reais" Key="ValorLimiteEmReais" ValueConverter="{StaticResource DecimalConverter}" Width="140" HorizontalContentAlignment="Right" IsHideable="False" />
                                        <ig:TextColumn HeaderText="Runoff" Key="RunOff" ValueConverter="{StaticResource RunOffConverter}" MinimumWidth="90" Width="90" HorizontalContentAlignment="Center" IsHideable="False" />
                                        <ig:TextColumn Key="QuantidadeOperacoesEnquadradas" MinimumWidth="122" Width="122" IsHideable="False" IsFilterable="False">
                                            <ig:TextColumn.HeaderTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="Operações Enquadradas" TextWrapping="Wrap"/>
                                                </DataTemplate>
                                            </ig:TextColumn.HeaderTemplate>
                                        </ig:TextColumn>
                                    </ig:XamGrid.Columns>

                                </ig:XamGrid>

                            </Grid>
                        </toolkit:Expander>

                    </Grid>

                    <Border x:Name="borderItemSublimite" Height="60"                         
                            Margin="0,2,0,2" Style="{StaticResource PainelInformacaoItau}"                            
                            Visibility="{Binding IsExpanded, ElementName=expSubLimites, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter='not'}" >

                        <Grid x:Name="panelItemSublimite" DataContext="{Binding}" VerticalAlignment="Stretch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <TextBlock Text="Descrição" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" 
                                   Margin="5,0,5,0" FontSize="12" FontWeight="Bold" FontFamily="Trebuchet MS"/>
                            <TextBlock Name="lblDescricao" Grid.Row="1" Grid.Column="0" Grid.RowSpan="2"  
                                   Margin="5,0,10,0" FontSize="12" FontFamily="Arial" TextWrapping="Wrap"
                                   Text="{Binding Descricao}" />

                            <TextBlock Text="Limite em Reais:" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontWeight="Bold" FontFamily="Trebuchet MS"/>
                            <TextBlock Name="lblValorLimiteEmReais" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontFamily="Arial"
                                   Text="{Binding ValorLimiteEmReais, Converter={StaticResource DecimalConverter}}"/>

                            <TextBlock Text="RunOff:" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontWeight="Bold" FontFamily="Trebuchet MS"/>
                            <TextBlock Name="lblRunOff" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontFamily="Arial"
                                   Text="{Binding RunOff, Converter={StaticResource RunOffConverter}}" />

                            <TextBlock Text="Operações Enquadradas:" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontWeight="Bold" FontFamily="Trebuchet MS"/>
                            <TextBlock Name="lblOpeEnquadradas" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right" 
                                   Margin="5,0,5,0" FontSize="12" FontFamily="Arial"
                                   Text="{Binding QuantidadeOperacoesEnquadradas}" />
                        </Grid>
                    </Border>
                </StackPanel>

                <Grid Name="gridOperacoes" Grid.Row="1" Margin="0,2,0,0"
                      Visibility="Collapsed">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <Grid Grid.Row="0" Name="panelHeaderOperacoes">

                        <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top">

                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Operações" Foreground="#FFE78E21" FontSize="14"/>
                                <TextBlock Name="lblNomeCliente" Text=" " Margin="5,0,0,0" FontSize="14" Foreground="#FFE78E21"/>
                            </StackPanel>
                            <Border Style="{StaticResource LineGold}" HorizontalAlignment="Left"/>

                            <CheckBox Name="chkSelecionarTodos" Content="Selecionar todos"
                                      Margin="6,3,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Click="chkSelecionarTodos_Click" />
                        </StackPanel>

                        <Border Style="{StaticResource borderOpcaoFiltro}" CornerRadius="6,6,0,0" Margin="0,0,0,-7"
                                HorizontalAlignment="Right" VerticalAlignment="Bottom">

                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Height="16">
                                <TextBlock Text="Filtro: " HorizontalAlignment="Left" Style="{StaticResource SubTitleHeader}" FontSize="11" Height="16"/>
                                <Image Source="{StaticResource IconeFiltro}" Height="16" Width="16" />

                                <CheckBox Name="chkFiltroEnquadrado" Content="Enquadrado" Click="FiltroGridOperacao_Click" IsChecked="false" Margin="10,0,0,0" Foreground="Black"  />
                                <sdk:Label Name="lblQtdEnquadrada" Content="0" Style="{StaticResource LegendGreen}" 
                                           HorizontalAlignment="Right" VerticalAlignment="Top" Margin="-4,-4,0,0"/>

                                <CheckBox Name="chkFiltroNaoEnquadrado" Content="Não Enquadrado" Margin="10,0,0,0" Click="FiltroGridOperacao_Click" IsChecked="true" Foreground="Black"  />
                                <sdk:Label Name="lblQtdNaoEnquadrada" Content="0" Style="{StaticResource LegendRed}" 
                                           HorizontalAlignment="Right" VerticalAlignment="Top" Margin="-4,-4,0,0" />

                            </StackPanel>
                        </Border>
                    </Grid>

                    <Grid Grid.Row="1">
                        <ig:XamGrid Name="grdOperacoes" Margin="0,5,0,15"
                                    AutoGenerateColumns="False">
                            <i:Interaction.Behaviors>
                                <behavior:XamGridBehavior x:Name="grdOperacoesBehavior" IsExpandRowGrouped="True" />
                            </i:Interaction.Behaviors>
                            
                            <ig:XamGrid.Columns>
                                <ig:TemplateColumn Key="Selecionado" HeaderText=" " Width="30" IsFilterable="False" IsGroupable="False" IsResizable="False" >
                                    <ig:TemplateColumn.ItemTemplate>
                                        <DataTemplate>
                                            <CheckBox Name="chkBxSelectSublimite" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                      IsChecked="{Binding Mode=TwoWay, Path=Selecionado}"
                                                      Click="chkBxSelectSublimite_Click" />
                                        </DataTemplate>
                                    </ig:TemplateColumn.ItemTemplate>
                                </ig:TemplateColumn>
                                <!--<ig:TextColumn Key="CodigoUnico" Visibility="Collapsed"/>-->
                                <ig:TextColumn HeaderText="Operação" Key="CodigoContrato" Width="150" />
                                <ig:TextColumn HeaderText="Produto / Modalidade" Key="CodigoProdutoModalidade" Width="160" TextWrapping="Wrap" />
                                <ig:TextColumn HeaderText="Sublimite Atual" Key="SubLimite" MinimumWidth="150" Width="0.40*" TextWrapping="Wrap"/>
                                <ig:TextColumn HeaderText="Comandado" Key="Comandado" Width="105" TextWrapping="Wrap" ValueConverter="{StaticResource ComandadoConverter}" HorizontalContentAlignment="Center" />
                                <ig:TemplateColumn HeaderText="Enquadramento Manual" Key="SubLimiteReenquadrado" MinimumWidth="200" Width="0.60*" >
                                    <ig:TemplateColumn.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="{StaticResource IconeBloqueado}" Width="16" Height="16"
                                                       ToolTipService.ToolTip="Sublimite Runoff. Favor re-enquadrar esta operação."
                                                       Visibility="{Binding ReenquadradoEmRunOff, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                                <TextBlock Text="{Binding SubLimiteReenquadrado}" TextWrapping="Wrap"
                                                           Foreground="{Binding ReenquadradoEmRunOff, Converter={StaticResource RunoffToBrushConverter}}"/>
                                            </StackPanel>
                                        </DataTemplate>
                                    </ig:TemplateColumn.ItemTemplate>
                                </ig:TemplateColumn>
                                <ig:TextColumn HeaderText="Status" Key="DescricaoStatus" Width="90" HorizontalContentAlignment="Center"/>
                                <ig:TextColumn HeaderText="Usuário" Key="UsuarioSolicitou" />
								<ig:TextColumn HeaderText="Data" Key="DataSolicitacao" HorizontalContentAlignment="Center"/>                                
                            </ig:XamGrid.Columns>

                        </ig:XamGrid>

                        <toolkit:BusyIndicator x:Name="activityOperacoes"/>

                    </Grid>
                </Grid>

            </Grid>
        </toolkit:BusyIndicator>        
    </Grid>
	
</navigation:Page>